package com.edu.whty.entity.cloud;

import com.alibaba.fastjson.annotation.JSONField;

/**
 * 请求分页参数
 * 
 * @author 
 * @date 2015年7月14日 下午3:31:51
 */
public class BoutiquePage {

	private Integer curPage = 1;// 请求页数
	private Integer numPerPage = 10;// 页大小
	private Integer recordCount = 0;// 记录数
	private Integer totalPage = 0;//总页数
	
	public BoutiquePage(){};
	
	public BoutiquePage(int curPage, int numPerPage) {
		this.curPage = curPage;
		this.numPerPage = numPerPage;
	}
	
	public BoutiquePage(int recordCount, int curPage, int numPerPage) {
		this.recordCount = recordCount;
		this.numPerPage = numPerPage;
		this.curPage = curPage;
	}

	/**
	 * 数据库查询开始记录数
	 * @return
	 */
	@JSONField(serialize = false)
	public Integer getStart() {
		return (curPage - 1) * numPerPage ;
	}
	
	/**
	 * 数据库查询结束记录数
	 * @return
	 */
	@JSONField(serialize = false)
	public Integer getEnd() {
		return curPage * numPerPage;
	}
	
	public Integer getCurPage() {
		return curPage;
	}

	public void setCurPage(Integer curPage) {
		this.curPage = curPage;
	}

	public Integer getNumPerPage() {
		return numPerPage;
	}

	public void setNumPerPage(Integer numPerPage) {
		this.numPerPage = numPerPage;
	}

	public Integer getRecordCount() {
		return recordCount;
	}

	public void setRecordCount(Integer recordCount) {
		this.recordCount = recordCount;
	}

	public Integer getTotalPage() {
		if (totalPage != null) {
			return totalPage;
		} else {
			int totalP = recordCount/numPerPage;
			if (recordCount%numPerPage == 0) {
				return totalP;
			} else {
				return totalP + 1;
			}
		}
	}

	public void setTotalPage(Integer totalPage) {
		this.totalPage = totalPage;
	}

	@Override
	public String toString() {
		return "PageInfo [curPage=" + curPage + ", numPerPage=" + numPerPage
				+ ", recordCount=" + recordCount + ", totalPage=" + totalPage
				+ "]";
	}
	 
 

}
